import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:寻找第K大
 * User: wangxin
 * Date: 2024-11-25
 * Time: 22:11
 */
public class test2 {
    //解法一
    public int findKth (int[] a, int n, int K) {
        // write code here
        PriorityQueue<Integer> p = new PriorityQueue<>(n);
        for(int i = 0; i < n;i++){
            p.offer(a[i]);
        }
        int res = 0;
        for(int i = n;i > 0;i--){

            if( i ==  K){
                return p.poll();
            }
            p.poll();
        }
        return -1;
    }
}
